﻿using System.Windows.Controls;
using System.Windows;
using System.Diagnostics;
using BaseTypesControlLib.Interfaces;

namespace BaseTypesControlLib.Controls
{
    public abstract class FieldControl:Control
    {

        protected override Size MeasureOverride(Size constraint)
        {
            Size sz = base.MeasureOverride(constraint);
            if (this is IUseAllWidth && ((IUseAllWidth)this).UseAllWidth)
                sz.Width = constraint.Width;
            if (this is IUseAllHeight && ((IUseAllHeight)this).UseAllHeight)
                sz.Height = constraint.Height;

           // Debug.WriteLine(string.Format("{4}: cw={0}, ch={1}, aw={2}, ah={3}", constraint.Width, constraint.Height, sz.Width, sz.Height, GetType().Name));
            return sz;
        }

        static FieldControl()
        {
            
        }

        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

        }
    }
}
